﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script type="text/javascript">
        /*
        var myApp = {}
        myApp.id = 0;
        myApp.next = function () {
            return myApp.id++;
        }

        myApp.reset = function () {
            myApp.id = 0;
        }

        //0, 1, undefined, 0 
        window.console && console.log(
            myApp.next(),
            myApp.next(),
            myApp.reset(),
            myApp.next()
        );
        */
        
        var myApp = {}
        myApp.id = 0;

        myApp.next = function () {
            return this.id++;
        }

        myApp.reset = function () {
            this.id = 0;
        }

        console.log(myApp);
        myApp.next(); //0
        myApp.next(); //1
        var getNextId = myApp.next;
        getNextId(); //NaN whoops!
    </script>
</head>
<body>
    
</body>
</html>